//导入创建好的axios实例
import {request} from '@/utils/httprequest';

export function deleteModel(id) {
    return request({
        url: '/model/' + id,
        method: 'delete',
    })
}

export function startPredict(id, data) {
    return request({
        url: '/model/predict/' + id,
        method: 'post',
        data: data,
        timeout: 3000000 // 设置超时时间为5秒钟
    }).catch(error => {
        if (error) {
            // 超时错误提示为"数据量过多"
            console.log('数据量过多，请重试');
        }
        throw error;
    });
}

export function startTrainModel(id, data) {
    return request({
        url: '/model/train/' + id,
        method: 'post',
        data: data,
        timeout: 3000000 // 设置超时时间为5秒钟

    }).catch(error => {
        if (error) {
            // 超时错误提示为"数据量过多"
            console.log('数据量过多，请重试');
        }
        throw error;
    });
}

export function getModelData() {
    return request({
        url: '/model',
        method: 'get',
    })
}

// 下载模型
export function downloadModel(model_id) {
    return request({
        url: '/model/download/' + model_id,
        method: 'get',
        responseType: 'blob',
    })
}

//上传模型信息
export function upLoadModel(data) {
    return request({
        url: '/model',
        method: 'post',
        data: data
    })
}